#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int a, b;
	int c = 0;
	scanf("%d %d", &a, &b);
	while(c=a%b)
	{
		a = b;
		b = c;

	}
	printf("%d",b );
	return 0;

}